/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "PROGRAMA")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Programa.findAll", query = "SELECT p FROM Programa p"),
    @NamedQuery(name = "Programa.findByProCod", query = "SELECT p FROM Programa p WHERE p.proCod = :proCod"),
    @NamedQuery(name = "Programa.findByProNom", query = "SELECT p FROM Programa p WHERE p.proNom = :proNom"),
    @NamedQuery(name = "Programa.findByProEst", query = "SELECT p FROM Programa p WHERE p.proEst = :proEst"),
    @NamedQuery(name = "Programa.findByProPre", query = "SELECT p FROM Programa p WHERE p.proPre = :proPre"),
    @NamedQuery(name = "Programa.findByProNpar", query = "SELECT p FROM Programa p WHERE p.proNpar = :proNpar"),
    @NamedQuery(name = "Programa.findByProPar", query = "SELECT p FROM Programa p WHERE p.proPar = :proPar"),
    @NamedQuery(name = "Programa.findByProMostrarweb", query = "SELECT p FROM Programa p WHERE p.proMostrarweb = :proMostrarweb"),
    @NamedQuery(name = "Programa.findByProTituloweb", query = "SELECT p FROM Programa p WHERE p.proTituloweb = :proTituloweb"),
    @NamedQuery(name = "Programa.findByProImagenweb", query = "SELECT p FROM Programa p WHERE p.proImagenweb = :proImagenweb"),
    @NamedQuery(name = "Programa.findByProDescripcionweb", query = "SELECT p FROM Programa p WHERE p.proDescripcionweb = :proDescripcionweb"),
    @NamedQuery(name = "Programa.findByProObjetivoweb", query = "SELECT p FROM Programa p WHERE p.proObjetivoweb = :proObjetivoweb"),
    @NamedQuery(name = "Programa.findByProDirigidoweb", query = "SELECT p FROM Programa p WHERE p.proDirigidoweb = :proDirigidoweb"),
    @NamedQuery(name = "Programa.findByProPrerreweb", query = "SELECT p FROM Programa p WHERE p.proPrerreweb = :proPrerreweb"),
    @NamedQuery(name = "Programa.findByProImgdescweb", query = "SELECT p FROM Programa p WHERE p.proImgdescweb = :proImgdescweb")})
public class Programa implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(generator="programaCodGen")
    @SequenceGenerator(name="programaCodGen", sequenceName="PROGRAMA_COD_GEN", allocationSize=1)
    @Column(name = "PRO_COD")
    private Integer proCod;
    @Basic(optional = false)
    @Column(name = "PRO_NOM")
    private String proNom;
    @Column(name = "PRO_EST")
    private Short proEst;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "PRO_PRE")
    private Double proPre;
    @Column(name = "PRO_NPAR")
    private Short proNpar;
    @Column(name = "PRO_PAR")
    private Double proPar;
    @Column(name = "PRO_MOSTRARWEB")
    private Integer proMostrarweb;
    @Column(name = "PRO_TITULOWEB")
    private String proTituloweb;
    @Column(name = "PRO_IMAGENWEB")
    private String proImagenweb;
    @Column(name = "PRO_DESCRIPCIONWEB")
    private String proDescripcionweb;
    @Column(name = "PRO_OBJETIVOWEB")
    private String proObjetivoweb;
    @Column(name = "PRO_DIRIGIDOWEB")
    private String proDirigidoweb;
    @Column(name = "PRO_PRERREWEB")
    private String proPrerreweb;
    @Column(name = "PRO_IMGDESCWEB")
    private String proImgdescweb;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "programa", fetch = FetchType.LAZY)
    private List<ProgramaModulo> programaModuloList;
    @OneToMany(mappedBy = "proCod", fetch = FetchType.LAZY)
    private List<ProgramaGrupo> programaGrupoList;
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

    public Programa() {
        this.proNom = "";
        this.proEst = 1;
    }

    public Programa(Integer proCod) {
        this();
        this.proCod = proCod;
    }

    public Programa(Integer proCod, String proNom) {
        this();
        this.proCod = proCod;
        this.proNom = proNom;
    }

    public Integer getProCod() {
        return proCod;
    }

    public void setProCod(Integer proCod) {
        Integer old = this.proCod;
        this.proCod = proCod;
        changeSupport.firePropertyChange("proCod", old, proCod);
    }

    public String getProNom() {
        return proNom;
    }

    public void setProNom(String proNom) {
        String old = this.proNom;
        this.proNom = proNom;
        changeSupport.firePropertyChange("proNom", old, proNom);
    }

    public Short getProEst() {
        return proEst;
    }

    public void setProEst(Short proEst) {
        Short old = this.proEst;
        this.proEst = proEst;
        changeSupport.firePropertyChange("proEst", old, proEst);
    }

    public Double getProPre() {
        return proPre;
    }

    public void setProPre(Double proPre) {
        Double old = this.proPre;
        this.proPre = proPre;
        changeSupport.firePropertyChange("proPre", old, proPre);
    }

    public Short getProNpar() {
        return proNpar;
    }

    public void setProNpar(Short proNpar) {
        Short old = this.proNpar;
        this.proNpar = proNpar;
        changeSupport.firePropertyChange("proNpar", old, proNpar);
    }

    public Double getProPar() {
        return proPar;
    }

    public void setProPar(Double proPar) {
        Double old = this.proPar;
        this.proPar = proPar;
        changeSupport.firePropertyChange("proPar", old, proPar);
    }

    public Integer getProMostrarweb() {
        return proMostrarweb;
    }

    public void setProMostrarweb(Integer proMostrarweb) {
        Integer old = this.proMostrarweb;
        this.proMostrarweb = proMostrarweb;
        changeSupport.firePropertyChange("proMostrarweb", old, proMostrarweb);
    }

    public String getProTituloweb() {
        return proTituloweb;
    }

    public void setProTituloweb(String proTituloweb) {
        String old = this.proTituloweb;
        this.proTituloweb = proTituloweb;
        changeSupport.firePropertyChange("proTituloweb", old, proTituloweb);
    }

    public String getProImagenweb() {
        return proImagenweb;
    }

    public void setProImagenweb(String proImagenweb) {
        String old = this.proImagenweb;
        this.proImagenweb = proImagenweb;
        changeSupport.firePropertyChange("proImagenweb", old, proImagenweb);
    }

    public String getProDescripcionweb() {
        return proDescripcionweb;
    }

    public void setProDescripcionweb(String proDescripcionweb) {
        String old = this.proDescripcionweb;
        this.proDescripcionweb = proDescripcionweb;
        changeSupport.firePropertyChange("proDescripcionweb", old, proDescripcionweb);
    }

    public String getProObjetivoweb() {
        return proObjetivoweb;
    }

    public void setProObjetivoweb(String proObjetivoweb) {
        String old = this.proObjetivoweb;
        this.proObjetivoweb = proObjetivoweb;
        changeSupport.firePropertyChange("proObjetivoweb", old, proObjetivoweb);
    }

    public String getProDirigidoweb() {
        return proDirigidoweb;
    }

    public void setProDirigidoweb(String proDirigidoweb) {
        String old = this.proDirigidoweb;
        this.proDirigidoweb = proDirigidoweb;
        changeSupport.firePropertyChange("proDirigidoweb", old, proDirigidoweb);
    }

    public String getProPrerreweb() {
        return proPrerreweb;
    }

    public void setProPrerreweb(String proPrerreweb) {
        String old = this.proPrerreweb;
        this.proPrerreweb = proPrerreweb;
        changeSupport.firePropertyChange("proPrerreweb", old, proPrerreweb);
    }

    public String getProImgdescweb() {
        return proImgdescweb;
    }

    public void setProImgdescweb(String proImgdescweb) {
        String old = this.proImgdescweb;
        this.proImgdescweb = proImgdescweb;
        changeSupport.firePropertyChange("proImgdescweb", old, proImgdescweb);
    }

    @XmlTransient
    public List<ProgramaModulo> getProgramaModuloList() {
        return programaModuloList;
    }

    public void setProgramaModuloList(List<ProgramaModulo> programaModuloList) {
        this.programaModuloList = programaModuloList;
    }

    @XmlTransient
    public List<ProgramaGrupo> getProgramaGrupoList() {
        return programaGrupoList;
    }

    public void setProgramaGrupoList(List<ProgramaGrupo> programaGrupoList) {
        this.programaGrupoList = programaGrupoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (proCod != null ? proCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Programa)) {
            return false;
        }
        Programa other = (Programa) object;
        if ((this.proCod == null && other.proCod != null) || (this.proCod != null && !this.proCod.equals(other.proCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
//        return "pe.edu.unmsm.cinfo.siga.datos.Programa[ proCod=" + proCod + " ]";
        return getProNom();
    }
    
    public void addPropertyChangeListener(PropertyChangeListener l){
        changeSupport.addPropertyChangeListener(null);
    }
    
    public void removePropertyChangeListener(PropertyChangeListener l){
        changeSupport.removePropertyChangeListener(null);
    }
}
